#define _CRT_SECURE_NO_WARNINGS   1

#include<iostream>
#include<stack>
#include<string>
using namespace std;

class Solution {
public:
	bool isValid(string s)
	{
		stack<char> st;
		for (int i = 0; i < s.length(); i++){
			if (s[i] == '(')
				st.push(')');
			else if (s[i] == '[')
				st.push(']');
			else if (s[i] == '{')
				st.push('}');
			else if (st.empty())
				return false;
			else if (st.top() == s[i])
				st.pop();
		}
		return st.empty();
	}
};
int main()
{
	string s;
	cin >> s;
	Solution ss;
	if (ss.isValid(s))
		cout << "True" << endl;
	else
		cout << "False" << endl;
	return 0;
}